package com.igeek.boot.mapper;

import com.igeek.boot.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2023-12-26
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    //根据adminId 查询 角色信息（包含权限）
    @Select("select r.* from role r,admin_role ar where r.id=ar.role_id and ar.admin_id=#{adminId}")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(
                    property = "permissions",javaType = Set.class ,
                    column = "id",
                    many = @Many(select = "com.igeek.boot.mapper.PermissionMapper.selectPermissionsByRoleId"))
    })
    public Set<Role> selectRolesByAdminId(Integer adminId);

}
